import 'dart:math';

class Point {
  double x = 0;
  double y = 0;

  // Point(double x, double y) {
  //   this.x = x;
  //   this.y = y;
  // }

  Point(this.x, this.y);

  Point.origin()
      : x = 1,
        y = 2;
}

class Person {
  String? firstName;

  Person.fromJson(Map data) {
    print('in Person');
  }
}

class Employee extends Person {
  // Person does not have a default constructor;
  // you must call super.fromJson(data).
  Employee.fromJson(Map data) : super.fromJson(data) {
    print('in Employee');
  }
}

class Point2 {
  final double x;
  final double y;
  final double distanceFromOrigin;
  late final Set other;

  Point2(double x, double y)
      : x = x,
        y = y,
        distanceFromOrigin = sqrt(x * x + y * y),
        other = {x, y};

  Point2.alongXAxis(double x) : this(x, 0);

}

void main() {
  var employee = Employee.fromJson({});
  print(employee);
  // Prints:
  // in Person
  // in Employee
  // Instance of 'Employee'

  var point2 = Point2(2, 3);
  print(point2.distanceFromOrigin);
  print(point2.other);
  print(Point2.alongXAxis(2).distanceFromOrigin);
}
